<?php
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');
/*Author's Statement:
This script is based on ideas of the author.
You may copy, modify and use it for any purpose. The only condition is that if you publish web pages that use this script you point to its author at a suitable place and don't remove the content part of the <meta name=AUTHOR>-tag  from it.
It's your responsibility to handle possible bugs even if you didn't modify anything. I cannot promise any support.
Dieter Bungers, Email: bungers@gmd.de and db@infovation.de
GMD (www.gmd.de) and infovation (www.infovation.de)*/
$showNumbers = false; 		// display the ordering strings: yes=true | no=false
$backColor = "#225599";		// background color of the ToC
$normalColor = "#FFFFFF";	// text color of the ToC headlines
$currentColor = "#FFFF00";	// text color of the actual line just clicked on
$titleColor = "#FFFFFF";		// text color of the title "Table of Contents"
$mLevel = 2;					// number of levels minus 1 the headlines of which are presentet with large and bold fonts
$textSizes = array(1, 0.7, 0.6, 0.8, 0.7);			// font-size factors for: [0] the title "Table of Contents", [1] larger and bold fonts [2] smaller fonts if MS Internet Explorer [3] larger and bold fonts [4] smaller fonts if Netscape Navigator.
$fontTitle = "Helvetica,Arial"; // font-family of the title "Table of Contents"
$fontLines = "Helvetica,Arial"; // font-family of the headlines
//require("tocParas.php3");
//require("tocTab.php3");
if($quit==1){
	echo "<html>
				<head>
				<meta http-equiv='refresh' content='3; URL=index.php3?&quit=1'>
				</head>
				<body><B>Closing...</b></body>
				</html>";
}
else{
require("mainmenu.php");
}
?>
<html>
<head>
<title>ToC</title>
<meta name="AUTHOR" content="Technique for ToC generation by Dieter Bungers, Email: bungers@gmd.de and db@infovation.de">
<meta http-equiv='Pragma' content='no-cache'>
<meta http-equiv='Expires' content='-1'>
</head>
<body bgcolor=<?php echo $backColor; ?>>
<table border=0 cellspacing=1 cellpadding=0>
<tr>
<?php
if($quit != 1){
	//echo "toc GO!!!\n";
	//echo "Toc tab 1.0 " .$tocTab[0][0] . " \n";
	$mdi=$textSizes[1];
	$sml=$textSizes[2];
	//$currentNumArray = explode(".",$currentNumber);
	//print_r($currentNumber);
	$currentNumArray = str_split($currentNumber);

	//echo "\n Curr Num Array :";
	//print_r($currentNumArray);
	$currentLevel = sizeof($currentNumArray)-1;
	$theHref = "";
	for ($i=0; $i<sizeof($tocTab); $i++) {
		$thisNumber = $tocTab[$i][0];
		$isCurrentNumber = ($thisNumber == $currentNumber);
		if ($isCurrentNumber) $theHref=$tocTab[$i][2];
		//$thisNumArray = explode(".",$thisNumber);
		$thisNumArray = str_split($thisNumber);
		$thisLevel = sizeof($thisNumArray)-1;
		$toDisplay = TRUE;
		if ($thisLevel > 0) {
			for ($j=0; $j<$thisLevel; $j++) {
				$toDisplay = ($j>$currentLevel)?FALSE:$toDisplay && ($thisNumArray[$j] == $currentNumArray[$j]);
			}
		}
		$thisIsExpanded = ($toDisplay && ($thisNumArray[$thisLevel] == $currentNumArray[$thisLevel])) ? 1 : 0;
		if ($currentIsExpanded=="1") {
			$toDisplay = $toDisplay && ($thisLevel<=$currentLevel);
			if ($isCurrentNumber) $thisIsExpanded = 0;
		}

		if ($toDisplay) {
			if ($i==0) {
				echo ("\n<td colspan=" . ($nCols+1) . "><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "\" style=\"font-family: " . $fontTitle . "; font-weight:bold; font-size:" . $textSizes[0] . "em; color: " . $titleColor . "; text-decoration:none\" target=\"_top\">" . $tocTab[$i][1] . "</a></td></tr>");
				for ($k=0; $k<$nCols; $k++) {
					echo "<td>&nbsp;</td>";
				}
				echo "<td width=240>&nbsp;</td></tr>\n";
			}
			else {
				$isLeaf = ($i==sizeof($tocTab)-1) || ($thisLevel >= sizeof(explode(".",$tocTab[$i+1][0]))-1);
				$img = ($isLeaf) ? "leaf" : (($thisIsExpanded)?"minus":"plus");
				echo "<tr>";
				for ($k=1; $k<=$thisLevel; $k++) {
					echo "<td>&nbsp;</td>";
				}
				echo ("<td valign=top><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "\" target=\"_top\"><img src=\"images/" . $img . ".gif\" width=13 height=12 border=0></a></td> <td colspan=" . ($nCols-$thisLevel) . "><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "\" style=\"font-family: " . $fontLines . ";" . (($thisLevel<=$mLevel)?"font-weight:bold":"") .  "; font-size:" . (($thisLevel<=$mLevel)?$mdi:$sml) . "em; color: " . (($isCurrentNumber)?$currentColor:$normalColor) . "; text-decoration:none\" target=\"_top\">" . (($showNumbers)?($thisNumber." "):"") . $tocTab[$i][1] . "</a></td></tr>\n");
			}
		}
	}
	echo ("<td valign=top><a href=\"index.php3?quit=1\" target=\"_top\"><img src=\"images/" . $img . ".gif\" width=13 height=12 border=0></a></td> <td colspan=" . ($nCols-$thisLevel) . "><a href=\"index.php3?quit=1\" style=\"font-family: " . $fontLines . ";" . (($thisLevel<=$mLevel)?"font-weight:bold":"") .  "; font-size:" . (($thisLevel<=$mLevel)?$mdi:$sml) . "em; color: " . (($isCurrentNumber)?$normalColor:$normalColor) . "; text-decoration:none\" target=\"_top\">" . "Logout" . "</a></td></tr>\n");
}
?>
<?
//echo ("\n<td colspan=" . ($nCols+1) . "><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "&user=". $user. "&pass=" .$pass. "&user_id=" .$user_id. "&company_sel=" .$company_sel. "&orcl=" .$orcl. "&prev_num=" .$prev_num. "\" style=\"font-family: " . $fontTitle . "; font-weight:bold; font-size:" . $textSizes[0] . "em; color: " . $titleColor . "; text-decoration:none\" target=\"_top\">" . $tocTab[$i][1] . "</a></td></tr>");
//echo ("<td valign=top><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "&user=". $user. "&pass=" .$pass. "&user_id=" .$user_id. "&company_sel=" .$company_sel. "&orcl=" .$orcl. "&prev_num=" .$prev_num. "\" target=\"_top\"><img src=\"Images/" . $img . ".gif\" width=13 height=12 border=0></a></td> <td colspan=" . ($nCols-$thisLevel) . "><a href=\"index.php3?currentNumber=" . rawurlencode($thisNumber) . "&currentIsExpanded=" . $thisIsExpanded . "&user=". $user. "&pass=" .$pass. "&user_id=" .$user_id. "&company_sel=" .$company_sel. "&orcl=" .$orcl. "&prev_num=" .$prev_num. "\" style=\"font-family: " . $fontLines . ";" . (($thisLevel<=$mLevel)?"font-weight:bold":"") .  "; font-size:" . (($thisLevel<=$mLevel)?$mdi:$sml) . "em; color: " . (($isCurrentNumber)?$currentColor:$normalColor) . "; text-decoration:none\" target=\"_top\">" . (($showNumbers)?($thisNumber." "):"") . $tocTab[$i][1] . "</a></td></tr>\n");
?>
</table>
</body>
</html>